package ui;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
//右下角的歌词按钮， 具体功能待实现
public class LrcButton extends Label implements MouseListener, MouseTrackListener{

	private boolean isActived;
	private Image deactive;
	private Image active;
	public LrcButton(Composite parent, int style) {
		super(parent, style);
	}
	@Override
	protected void checkSubclass() {};
	public void initial(Image deactive, Image active) {
		this.deactive = deactive;
		this.active = active;
		addMouseListener(this);
		addMouseTrackListener(this);
		
	}
	@Override
	public void mouseEnter(MouseEvent e) {
		if (!isActived) {
			setImage(active);
		}
	}
	@Override
	public void mouseExit(MouseEvent e) {
		if(!isActived) {
			setImage(deactive);
		}
		
	}
	@Override
	public void mouseHover(MouseEvent e) {}
	@Override
	public void mouseDoubleClick(MouseEvent e) {}
	@Override
	public void mouseDown(MouseEvent e) {}
	@Override
	public void mouseUp(MouseEvent e) {
		isActived =! isActived;
		if (!isActived) {
			setImage(deactive);
			ui.global.Operation.getLrcView().setVisible(false);
		}else {
			ui.global.Operation.getLrcView().setVisible(true);
		}
	}
}
